home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / m_to_r / reporter / pstatus.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  1.9 KB  |  81 lines

  1. unit Pstatus;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Gauges;
  8.  
  9. type
  10.   TPrintStatusForm = class(TForm)
  11.     Label2: TLabel;
  12.     Label3: TLabel;
  13.     ProgressGauge: TGauge;
  14.     CancelButton: TButton;
  15.     procedure FormShow(Sender: TObject);
  16.     procedure CancelButtonClick(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.     Canceled : Boolean;
  22.  
  23.     CurrentPage : Word;
  24.     PrintStatus : String;
  25.     PrinterName : String;
  26.  
  27.     Procedure UpdateStatus;
  28.   end;
  29.  
  30. var
  31.   PrintStatusForm: TPrintStatusForm;
  32.  
  33. implementation
  34.  
  35. {$R *.DFM}
  36.  
  37. Procedure tPrintStatusForm.UpdateStatus;
  38. Var
  39.    StatusWidth : Word;
  40. Begin
  41.      If Canceled Then
  42.      Begin
  43.           Application.ProcessMessages;
  44.           Exit;
  45.      End;
  46.  
  47.      Caption := PrintStatus;
  48.      Label2.Caption := 'To ' + PrinterName;
  49.      Label3.Caption := 'Page ' + IntToStr ( CurrentPage );
  50.  
  51.      StatusWidth := Label2.Width;
  52.      If Label3.Width > StatusWidth Then StatusWidth := Label3.Width;
  53.      If ProgressGauge.Width > StatusWidth Then StatusWidth := ProgressGauge.Width;
  54.      If CancelButton.Width > StatusWidth Then StatusWidth := CancelButton.Width;
  55.  
  56.      ClientWidth := 32 + StatusWidth;
  57.      Label2.Width := StatusWidth;
  58.      Label3.Width := StatusWidth;
  59.  
  60.      ProgressGauge.Left := ( ClientWidth - ProgressGauge.Width ) Div 2;
  61.      CancelButton.Left  := ( ClientWidth - CancelButton.Width ) Div 2;
  62.  
  63.      Left := ( Screen.Width - ClientWidth ) Div 2;
  64.      Top  := ( Screen.Height - ClientHeight ) Div 2; 
  65.  
  66.      Application.ProcessMessages;
  67. End;
  68.  
  69. procedure TPrintStatusForm.FormShow(Sender: TObject);
  70. begin
  71.      Canceled := False;
  72. end;
  73.  
  74. procedure TPrintStatusForm.CancelButtonClick(Sender: TObject);
  75. begin
  76.      Canceled := True;
  77.      Caption := 'Aborting...';
  78. end;
  79.  
  80. end.
  81.